<?php
class ProductAction extends Action{
    
    public function listproduct(){
        tsLoad('/webyufei/busi/ProductPage.class.php');
        session_start();
        if(isset($_GET['currentPage']))
            $currentPage = $_GET['currentPage'];
        else 
            $currentPage =1;
        
        $productPage = new ProductPage();
        $pageInfo = $productPage->initPage($_GET, 50, $currentPage);
        $productsData = $productPage->getCurPageData();
        //下次还需要的URL
        if(isset($_GET['prodTypeId']) && $_GET['prodTypeId']!=0)
            $url = '/listproduct?prodTypeId='.$_GET['prodTypeId'];
        else 
            $url = '/listproduct?s=sec';
        if(isset($_GET['lowPrice']))
            $url.='&lowPrice='.$_GET['lowPrice'];
        if(isset($_GET['highPrice']))
            $url.='&highPrice='.$_GET['highPrice'];
        if(isset($_GET['sortName']))
            $url.='&sortName='.$_GET['sortName'];
        if(isset($_GET['sortType']))
            $url.='&sortType='.$_GET['sortType'];
        if(isset($_GET['type']))
            $url.='&type='.$_GET['type'];
        if(isset($_GET['navTypeId']))
            $url.='&navTypeId='.$_GET['navTypeId'];
        
        $singleUrl = '/listproduct?f=a';
        if(isset($_GET['keyword'])){
            $url.='&keyword='.$_GET['keyword'];
            $singleUrl.='&keyword='.$_GET['keyword'];
        }else{
            $singleUrl.='&s=sec';
        }
        if(isset($_GET['type']))
            $singleUrl.='&type='.$_GET['type'];
        if(isset($_GET['navTypeId']))
            $singleUrl.='&navTypeId='.$_GET['navTypeId'];
        
        $this->assign('listproductsUrl',$url);
        $this->assign('listproductsSingleUrl',$singleUrl);
        $this->assign('productsData',$productsData);
        $this->assign('pageInfo',$pageInfo);
        
        $productTypeList = null;
        if(isset($_GET['prodTypeId']) && $_GET['prodTypeId']!=0)
            $productTypeList = $productPage->queryProductTypeListByProdId($_GET['prodTypeId']);
        $this->assign('productTypeList',$productTypeList);
        
        //分类ID保存
        $this->assign('prodTypeId',isset($_GET['prodTypeId'])?$_GET['prodTypeId']:0);
        $this->assign('type',isset($_GET['type'])?$_GET['type']:null);
        $this->assign('navTypeId',isset($_GET['navTypeId'])?$_GET['navTypeId']:0);
        
        //关键字保留
        $this->assign('keyword',isset($_GET['keyword'])?$_GET['keyword']:'');
        
        //排序说明
        $this->assign('sortName',isset($_GET['sortName'])?$_GET['sortName']:'');
        $this->assign('sortType',isset($_GET['sortType'])?$_GET['sortType']:'');
        
        //保存价格参数
        $this->assign('lowPrice',isset($_GET['lowPrice'])?$_GET['lowPrice']:0);
        $this->assign('highPrice',isset($_GET['highPrice'])?$_GET['highPrice']:0);
    }
}
?>